<?php
/**********************
**logout.php
**Date Created: 4/13/2009
**Copyright 2009 Tomorrow Tech Industries
**Contact: RPITomorrowTech@gmail.com
**********************/

require_once("private/login.inc");
require_once("private/user.inc");

function clearLogin()
{
	/**
	 * Delete cookies - the time must be in the past,
	 * so just negate what you added when creating the
	 * cookie.
	 */
	if( isset($_COOKIE['cookname']) && isset($_COOKIE['cookpass']) )
	{
		setcookie("cookname", "", time()-60*60*24*100, "/");
		setcookie("cookpass", "", time()-60*60*24*100, "/");
	}

	if( checkLogin() )
	{
	   //Kill session variables
	   unset($_SESSION['username']);
	   unset($_SESSION['password']);
	   $_SESSION = array(); // reset session array
	   session_destroy();   // destroy session.
	}
}

function displayPage()
{
	clearLogin();
	
	echo "
		<html>
		<title>Logging Out</title>
		<head>
		<meta http-equiv=\"refresh\" content=\"0;URL=index.php\" />
		</head>
		</html>
	";
	}


displayPage();

?>
